package tankgame6;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class HspTankGame06 extends JFrame {

    //定义一个MyPanel
    MyPanel mp = null;
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        HspTankGame06 hspTankGame01 = new HspTankGame06();



    }

    public HspTankGame06() {
        System.out.println("请输入选择 1.新游戏 2.继续上局");
        String key = scanner.next();
        mp = new MyPanel(key);
        this.add(mp);
        Thread thread = new Thread(mp);
        thread.start();
        this.addKeyListener(mp);
        this.setSize(1500, 750);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //在JFrame中增加相应关闭窗口的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecorder();
                System.exit(0);

            }
        });
    }
}
